import { request } from './request'

/**
 * 上传图片到OSS
 * @param file 图片文件
 * @returns 图片URL
 */
export const uploadImage = async (file: File): Promise<string> => {
  const formData = new FormData()
  formData.append('file', file)
  
  const res = await request<{ url: string }>({
    url: '/admin/upload/image',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
  
  return res.data.url
}

